package one.bugu.android.demon.ui.adapter;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.juefeng.android.framework.common.base.BaseListAdapter;

import com.juefeng.android.framework.common.util.StringUtil;

import one.bugu.android.demon.R;
import one.bugu.android.demon.bean.BGTInfoBean;
import one.bugu.android.demon.bean.VoiceBean;
import one.bugu.android.demon.common.MyBaseActivity;

public class VoiceInfoAdapter extends BaseListAdapter<VoiceBean> {

    private Context context;

    public VoiceInfoAdapter(Context context) {
        super(context);
        this.context = context;
    }

    @Override
    public int getContentLayoutId() {
        return R.layout.item_voiceinfo;
    }

    @Override
    public BaseListAdapter.ViewHolder getViewHolder() {
        return new VoiceInfoAdapter.Holder();
    }

    public class Holder implements BaseListAdapter.ViewHolder<VoiceBean> {

        /**
         * bgt数量
         */
        private TextView voiceNum;

        /**
         * 时间
         */
        private TextView voiceTime;

        /**
         * 类型
         */
        private TextView voiceTitle;

        /**
         * 图片类型
         */
        private ImageView typeImg;

        @Override
        public void initView(View view) {

            voiceNum = view.findViewById(R.id.voice_num);
            voiceTime = view.findViewById(R.id.voice_time);
            voiceTitle = view.findViewById(R.id.voice_title);
            typeImg = view.findViewById(R.id.voiceType_img);
        }

        @SuppressLint("SetTextI18n")
        @Override
        public void initData(VoiceBean voiceBean) {
            if (!StringUtil.isEmpty(voiceBean.getOptTime())) {
                voiceTime.setText(voiceBean.getOptTime().substring(0, voiceBean.getOptTime().indexOf(".")));
            }
            String string = voiceBean.getRemark();
            if (voiceBean.getOptType().equals("20")) {
                voiceTitle.setText("新用户赠送");
                voiceNum.setText("+" + voiceBean.getNum());
                typeImg.setImageResource(R.mipmap.yuyin_zengsong);
                voiceNum.setTextColor(Color.parseColor("#333333"));

            } else if (voiceBean.getOptType().equals("10")) {
                voiceTitle.setText("购买");
                voiceNum.setText("+" + voiceBean.getNum());
                typeImg.setImageResource(R.mipmap.yuyin_chongzhi);
                voiceNum.setTextColor(Color.parseColor("#333333"));

            } else if (voiceBean.getOptType().equals("40")) {
                voiceTitle.setText("使用扣除");
                voiceNum.setText("-" + voiceBean.getNum());
                voiceNum.setTextColor(Color.parseColor("#FE7361"));
                typeImg.setImageResource(R.mipmap.yuyin_kouchu);
            } else if (voiceBean.getOptType().equals("30")) {
                voiceTitle.setText("邀请奖励");
                voiceNum.setText("+" + voiceBean.getNum());
                typeImg.setImageResource(R.mipmap.yuyin_yaoqing);
                voiceNum.setTextColor(Color.parseColor("#333333"));

            } else if (voiceBean.getOptType().equals("50")) {
                voiceTitle.setText("返还");
                voiceNum.setText("+" + voiceBean.getNum());
                typeImg.setImageResource(R.mipmap.yuyin_fanhuan);
                voiceNum.setTextColor(Color.parseColor("#333333"));

            } else if (voiceBean.getOptType().equals("50")) {
                voiceTitle.setText("返还");
                voiceNum.setText("+" + voiceBean.getNum());
                typeImg.setImageResource(R.mipmap.yuyin_fanhuan);
                voiceNum.setTextColor(Color.parseColor("#333333"));

            } else if ("80".equals(voiceBean.getOptType())) {
                voiceNum.setTextColor(Color.parseColor("#333333"));
                voiceTitle.setText(voiceBean.getRemark());
                voiceNum.setText("+" + voiceBean.getNum());
                typeImg.setImageResource(R.mipmap.bgt_duihuan_d);
            }
        }

        @Override
        public void initEvent(VoiceBean voiceBean) {

        }
    }
}
